package com.bw.redis.consumer;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSONObject;
import com.bw.redis.config.DictionaryConstant;
import com.bw.redis.domain.SysDictionaryContent;
import com.ruoyi.common.redis.service.RedisService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(consumerGroup = "group2",topic = "ddd")
public class RcoketConsumer2 implements RocketMQListener {
    @Autowired
    private RedisService redisService;
    @Override
    public void onMessage(Object o) {
        String s = o.toString();
        System.out.println("vdvfvvvvvvvvvvvvvvvvvvvvvvvvv"+s);
        SysDictionaryContent dictionaryConstant = JSONObject.parseObject(o.toString(), SysDictionaryContent.class);
        if(redisService.hasKey("cdict"+dictionaryConstant.getDictId())){
            redisService.deleteObject("cdict"+dictionaryConstant.getDictId());
        }
    }
}
